﻿@model Masuit.MyBlogs.Core.Models.ViewModel.IpInfo
@{
    ViewBag.Title = "获取IP机房和路由信息";
    Layout = "~/Views/Shared/_Layout.cshtml";
}
<style>
    #allmap {
        height: 900px;
        width: 100%;
    }
</style>
<div class="container">
    <ol class="cd-breadcrumb triangle">
        <li><a asp-controller="Home" asp-action="Index">首页</a></li>
        <li class="current">
            <em>@ViewBag.Title</em>
        </li>
    </ol>
    <ul class="list-group">
        <li class="list-group-item">
            <p class="size24">
                如果你觉得这个工具有用，请 <a asp-controller="Misc" asp-action="Donate">点击这里</a> 支持一下博主！
            </p>
        </li>
        <li class="list-group-item">
            <p class="text-red">
                特别提示：由于IP地址存在多变性，本工具查询结果仅供参考，无法保证100%的准确性和精确性，请根据自己的实际情况酌情使用！
            </p>
        </li>
    </ul>
    <form method="get" asp-action="GetIpInfo">
        <div class="input-group">
            <input class="form-control" name="ip" value="@ViewBag.IP" placeholder="请输入有效的IPv4地址" />
            <span class="input-group-btn">
                <button class="btn btn-info" type="submit">查询</button>
            </span>
        </div>
    </form>
    <table class="table table-bordered table-condensed table-hover">
        <tr>
            <td>IP路由信息：</td>
            <td>@Model.Network.Router</td>
        </tr>
        <tr>
            <td>IP机房信息：</td>
            <td>@Model.Network.Organization</td>
        </tr>
        <tr>
            <td>ASN：</td>
            <td>@Model.Network.Asn</td>
        </tr>
        <tr>
            <td>参考地理位置1：</td>
            <td>@Model.Address</td>
        </tr>
        <tr>
            <td>参考地理位置2：</td>
            <td>@Model.Address2</td>
        </tr>
        <tr>
            <td>时区：</td>
            <td>@Model.TimeZone</td>
        </tr>
        <tr>
            <td>经纬度：</td>
            <td>(经度：@(Model.Location.Longitude),纬度：@(Model.Location.Latitude))</td>
        </tr>
        <tr>
            <td>代理或任播节点：</td>
            <td>@Model.IsProxy</td>
        </tr>
        <tr>
            <td>域名解析：</td>
            <td>@Model.Domain</td>
        </tr>
    </table>
</div>
<div class="container-fluid">
    @if (Model.Location != null)
    {
        <div id="allmap"></div>
        <script type="text/javascript" src="https://api.map.baidu.com/api?type=webgl&v=2.0&ak=89772e94509a9b903724e247cbc175c2"></script>
        <script>
            var map = new BMapGL.Map("allmap"); // 创建Map实例,设置地图允许的最小/大级别

            map.centerAndZoom(new BMapGL.Point(@(Model.Location.Longitude), @(Model.Location.Latitude)), 14-@Model.Location.AccuracyRadius.GetValueOrDefault().ToString().Length);
	        map.enableScrollWheelZoom(true);
	        var new_point = new BMapGL.Point(@(Model.Location.Longitude), @(Model.Location.Latitude));
            var marker = new BMapGL.Marker(new_point); // 创建标注
            var circle = new BMapGL.Circle(new_point, @Model.Location.AccuracyRadius.GetValueOrDefault()* 100, {
                strokeColor: 'blue',
                strokeWeight: 2,
                strokeOpacity: 0.1
            });
	        map.addOverlay(marker); // 将标注添加到地图中
            map.addOverlay(circle); // 将标注添加到地图中
	        marker.setAnimation(BMAP_ANIMATION_BOUNCE); //跳动的动画
	        map.panTo(new_point);
        </script>
    }
</div>